package ec;

import ge.CodonIterator;
import ge.Expression;
import ge.GESolution;
import ge.standardsymbols.StartSymbol;

public abstract class ECFitnessEvaluator implements FitnessEvaluator {
	public String getCode(Solution solution) {
		GESolution ge_solution = (GESolution) solution;
		CodonIterator iter = ge_solution.iterator();
		Expression exp = StartSymbol.resolve(iter);
		String code = exp.createInstance().getCode();

		solution.setSolutionString(code);
		ge_solution.setExtraString(" used_codons=" + iter.getNumCalls());

		return code;
	}

	public boolean compare(double fitnessA, double fitnessB) {
		return (fitnessA > fitnessB);
	}
	
	public double getWorstFitness() {
		return Double.NEGATIVE_INFINITY;
	}
}
